$().ready(function() {
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/sz/bd/update",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			carHolderName : {
				required : true
			},
			carHolderIdcard : {
				required : true
			},
			carHolderPhone : {
				required : true,
				digits: true
			},
			carHolderAddress : {
				required : true
			},
			bdValid : {
				required : true
			},
			vinCode : {
				required : true
			},
			egineNo : {
				required : true
			},
			carSupplier : {
				required : true
			},
			carTypeNo : {
				required : true
			},
			productNo : {
				required : true,
				digits: true
			},
			bdStartDate : {
				required : true
			}
		},
		messages : {
			carHolderName : {
				required : icon + "请输入车主姓名"
			},
			carHolderIdcard : {
				required : icon + "请输入车主身份证号"
			},
			carHolderPhone : {
				required : icon + "请输入车主移动电话"
			},
			carHolderAddress : {
				required : icon + "请输入车主联系方式"
			},
			bdValid : {
				required : icon + "请选择保单期限"
			},
			vinCode : {
				required : icon + "请输入VIN码"
			},
			egineNo : {
				required : icon + "请输入发动机号"
			},
			carSupplier : {
				required : icon + "请输入车辆厂牌"
			},
			carTypeNo : {
				required : icon + "请输入车辆型号"
			},
			productNo : {
				required : icon + "请输入产品编号"
			},
			bdStartDate : {
				required : icon + "请输入安装日期"
			}
		}
	})
}